package com.ponxu.web.core;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Action 基类
 * 
 * @author xwz
 * 
 */
public class Action {
	/**
	 * 执行Action前调用, 返回结果影响是否继续执行
	 * 
	 * @return
	 */
	public boolean before(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		return true;
	}

	/**
	 * 默认Action, 没有指定operation参数时调用
	 * 
	 * @return
	 */
	public String execute(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		return null;
	}

	/**
	 * 执行Action之后调用, 可以做一些善后工作, 可再次影响执行结果
	 * 
	 * @param result
	 *            Action的执行结果
	 * @return
	 */
	public String after(HttpServletRequest request,
			HttpServletResponse response, String result)
			throws ServletException, IOException {
		return result;
	}
}
